home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1987 July
/
1987-07.d64
/
calendar maker
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
68 lines
2 rem copyright 1987 compute! publications, inc. - all rights reserved
4 rem drive# printer# reverse on reverse off spacer
6 dr=8:pr=4:rv$=chr$(18):ro$=chr$(146):sp$="*"
8 s1$=" ":fori=1to21:sx$=sx$+s1$:next:s6$=left$(sx$,6):na$=chr$(0)
10 printchr$(142)chr$(8):dimm(12),y$(4),q$(6),h$(25),c$(6),m$(4)
12 fori=1to12:readm(i):next:readd$:d$=d$+" "+d$+" "+d$
14 fori=1to4:reada$,b$,c$:m$(i)=s6$+a$+left$(sx$,15)+b$+left$(sx$,15)+c$:next
16 fori=1to31:q$=q$+right$(str$(i),2)+" ":next:readf$
18 fm$=chr$(17)
20 rem --- parse year ---
22 printchr$(147)" copyright 1987 compute! pub., inc."
24 printtab(10)"all rights reserved"
26 printfm$tab(13)"calendar maker":printtab(13)"--------------"fm$
28 input"what year would you like";y$:iflen(y$)=2theny$="19"+y$
30 y=val(y$):ify<1900ory>2050goto26
32 forj=1to4:fori=.to4:y$(j)=y$(j)+mid$(f$,i*10+val(mid$(y$,j,1))+1,1)
34 next:next
36 rem --- get text ---
38 printfm$"enter text (254 char. max).":printfm$">> ";
40 geta$:ifa$=""then40
42 ifa$=chr$(13)goto52
44 ifa$=chr$(20)andn$>""thenn$=left$(n$,len(n$)-1):goto48
46 on-(a$<" "or(a$>chr$(127)anda$<chr$(160))orlen(n$)=254)goto40:n$=n$+a$
48 printa$;:goto40
50 rem --- reverse? ---
52 print:printfm$"reverse year heading? (y/n) ":gosub120
54 on-(a$="y")-(a$="n")*2goto60,56:goto52
56 rv$=na$:ro$=na$:s1$=sp$
58 rem --- where? ---
60 printfm$"(s)creen, (p)rinter, or (d)isk?":gosub120
62 on-(a$="s")-(a$="p")*2-(a$="d")*3goto76,64,70:goto52
64 printfm$"set up printer and hit any key..."
66 getb$:ifb$=""then66
68 goto76
70 open15,dr,15,"i0:":open3,dr,3,"0:"+y$+" calendar,s,w"
72 input#15,b$,c$:ifb$<"19"goto80
74 close3:close15:printfm$"disk error -- "b$" "c$:fori=1to2000:next:goto60
76 open3,3-((a$="p")+(pr=5))
78 rem --- print heading ---
80 printfm$"working...":fori=1toint(255/(len(n$)+1)):aa$=aa$+n$+s1$:next
82 fori=1to17step4:p=.:fork=1to4:b=val(mid$(y$(k),i/4+1,1)):forl=2to.step-1
84 if(band2^l)=.thenforj=itoi+3:h$(j)=h$(j)+na$+" "+na$:next:goto88
86 forj=itoi+3:h$(j)=h$(j)+rv$+mid$(aa$,j+p*5,5)+ro$:next
88 p=p+1:next:next:next:a$=" ":l=21:fori=1to20
90 n$=left$(h$(i),l)+a$+mid$(h$(i),22,l)+a$+mid$(h$(i),43,l)+a$+right$(h$(i),l)
92 print#3,s6$+" "+n$:next:print#3:print#3:print#3:m=1
94 rem --- print calendar ---
96 z=int(365.25*(y-1))+int(30.6*(m+13))-1
98 fori=1to10step3:forj=itoi+2:d=m(m)+(y/4=int(y/4))*(m=2)
100 ifright$(y$,2)="00"thenyc=val(left$(y$,2)):d=d-(yc/4<>int(yc/4))*(m=2)
102 z=z-int(z/7)*7:q$(1)=left$(left$(sx$,3*z)+q$,21):l=7-z:k=1:a=.
104 k=k+1:b=a:a=(l+7+d-abs(l+7-d))/2:z=a-b
106 q$(k)=left$(mid$(q$,3*l+1,3*z)+sx$,21)
108 l=l+7:on-(a<d)goto104:ifk=5thenq$(6)=sx$
110 fork=1to6:c$(k)=c$(k)+" "+q$(k):q$(k)=sx$:next:m=m+1:next
112 print#3,s6$+m$(j/3):print#3:print#3,s6$+d$:fork=1to6
114 print#3," "+c$(k):c$(k)="":next:print#3:next:fori=1to3:print#3:next
116 close3:close15:printfm$"done...hit any key to continue":gosub120:print
118 printfm$"make another? (y/n)":gosub120:on-(a$<>"y")goto126:run
120 geta$:ifa$=""then120
122 return
124 rem --- data ---
126 data31,28,31,30,31,30,31,31,30,31,30,31
128 data" su mo tu we th fr sa "
130 data" january","february"," march"," april "," may "," june"
132 data" july "," august ","september"," october","november","december"
134 data"72775777775611544155527377717752411151517777177177"